﻿using System;
using System.Collections.Generic;

namespace Wrox.ProCSharp.Delegates
{
    class Program
    {
        static void Main()
        {
            ////IList<Employee> employees;
            //employees.Add("Bugs Bunny", 20000);
            Employee[] employees =
            {
                new Employee("阿健宝贝",9999999999,18),
                new Employee("小李a", 10000,65),
                new Employee("ajbaobei", 25000,17),
                new Employee("小乔", 1000000,84),
                new Employee("结衣老师", 50000,50)
            };
            //Console.ForegroundColor//获取或设置控制台的前景色。
            //Console.BackgroundColor//获取或设置控制台的背景色。

            Console.WriteLine();
            Red();
            Console.WriteLine("薪资升序");
            Green();
            BubbleSorter.Sort(employees, Employee.CompareSalary);
            foreach (var employee in employees)
            {
                Console.WriteLine(employee);
            }
            Console.WriteLine();
            Red();
            Console.WriteLine("年龄升序");
            Green();

            BubbleSorter.Sort(employees, Employee.CompareSalaryAge);
            foreach (var employee in employees)
            {
                Console.WriteLine(employee);
            }
            Console.WriteLine();
            Red();
            Console.WriteLine("名字排序");
            Green();
            BubbleSorter.Sort(employees, Employee.CompareSalaryName);
            foreach (var employee in employees)
            {
                Console.WriteLine(employee);
            }
        }
        private static void Green()
        {
            Console.ForegroundColor = ConsoleColor.Green;
        }

        private static void Red()
        {
            Console.ForegroundColor = ConsoleColor.Red;
        }
    }
}
